//
//  deLISTTableViewCell.m
//  GOGOTravel
//
//  Created by dllo on 16/1/28.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "deLISTTableViewCell.h"

@implementation deLISTTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.label = [[BaseLabel alloc] init];
        [self.contentView addSubview:_label];
        [_label release];
        
    }
    return self;
}
- (void)dealloc{
    [_model release];
    [_label release];
    [super dealloc];
}

- (void)setModel:(Spot *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"yeJianMoShi" object:nil];
    
    
    //获取当前cell高度
    CGRect frame = [self frame];

    //文本赋值
    _label.text = _model.text;
    //获取字体样式
    NSDictionary *att = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    NSString *str = _model.text;
    //设置label的最大行数
    _label.numberOfLines = 30;
    
    
    
    CGRect rect = [str boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 40, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:att context:nil];
    
    _label.frame = CGRectMake(20, 20, [UIScreen mainScreen].bounds.size.width - 40,rect.size.height);
    
    //计算出自适应的高度
    
    frame.size.height = rect.size.height+30;
    self.frame = frame;
    
}
- (void)changeColor:(NSNotification *)notification{
    
    _label.textColor = [UIColor whiteColor];
    
    
}
- (void)layoutSubviews{
    
    
    [super layoutSubviews];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
